import 'package:development_assistant/config/colors.dart';
import 'package:development_assistant/config/fonticon.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:google_nav_bar/google_nav_bar.dart';
class CustomBottomNav extends StatelessWidget {
  const CustomBottomNav({super.key,required this.changePage});
  final Function(int) changePage;

  @override
  Widget build(BuildContext context) {
    var selectIndex=0.obs;
    if(Get.arguments!=null){
      selectIndex.value=Get.arguments["selectIndex"];
      print(Get.arguments["selectIndex"]);
    }
    return Container(
      height: 50.h,
      width: 360.w,
      margin: EdgeInsets.symmetric(horizontal: 10.w,vertical: 10.h),
      padding: EdgeInsets.symmetric(horizontal: 20.w),
      decoration: BoxDecoration(
        gradient: ColorsConfig().navColorOfTheme,
        borderRadius: BorderRadius.circular(25),
      ),
      child: Obx(()=>GNav(
        onTabChange: (e){
          selectIndex.value=e;
          changePage(e);
        },
        selectedIndex: selectIndex.value,
        color: ColorsConfig().navIconColorsOfTheme,
        activeColor: Colors.white,
        tabBackgroundColor:ColorsConfig().buttonColorOfTheme,
        padding: const EdgeInsets.symmetric(vertical: 10,horizontal: 10),
        gap: 10,
        tabs: [
          GButton(
            icon: FontIcons.serverNav,
            text: "服务器".tr,
          ),
          GButton(
            icon: FontIcons.apiManageNav,
            text: "接口".tr,
          ),
          GButton(
            icon: FontIcons.testNav,
            text: "测试".tr,
          ),
          GButton(
            icon: FontIcons.databaseNav,
            text: "数据库".tr,
          )
        ],
      )),
    ) ;
  }
}
